package com.cf.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cf.domain.pojo.JudgesScore;
import com.cf.domain.vo.TeamOrderVO;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

/**
 * @Author lzqinga@126.com
 * @Date 2024/11/11  20:36
 */
public interface JudgesScoreMapper extends BaseMapper<JudgesScore> {

    @Select("SELECT tt.user_id, tt.ground_id, tt.sort, tt.score, tt.is_score, tu.type FROM t_judges_score tt left join t_user tu ON tt.user_id = tu.id " +
            "WHERE tt.is_score = 1 AND tt.user_id = #{userId} ORDER BY tt.sort DESC")
    @Results({
            @Result(property = "team", column = "user_id", one = @One(select = "com.cf.mapper.TeamMapper.getTeamByUserId", fetchType= FetchType.DEFAULT)),
            @Result(property = "user", column = "user_id", one = @One(select = "getUserById", fetchType= FetchType.DEFAULT)),
            @Result(property = "ground", column = "ground_id", one = @One(select = "getGroundById", fetchType= FetchType.DEFAULT))
    })
    List<TeamOrderVO> getListByUserId(Long userId);
}
